package nc.vo.arap.util;

import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import nc.bs.dao.BaseDAO;
import nc.jdbc.framework.processor.ColumnProcessor;
import nc.vo.pub.BusinessException;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

public class FormatDataUtils {
	private static BaseDAO dao = new BaseDAO();
	
	/**
	 * json转化为xml格式默认<字段名称>
	 * @param json
	 * @return
	 */
	public static String jsonToXml(JSONObject json) {
		try {
			StringBuffer buffer = new StringBuffer();
			jsonToXmlstr(json, buffer);
			return buffer.toString();
		} catch (Exception e) {
			e.printStackTrace();
			return "";
		}
	}

	public static String jsonToXmlstr(JSONObject jObj, StringBuffer buffer) {
		Set<Map.Entry<String, Object>> se = jObj.entrySet();
		for (Iterator<Map.Entry<String, Object>> it = se.iterator(); it.hasNext();) {
			Map.Entry<String, Object> en = it.next();
			if (en.getValue().getClass().getName().equals("com.alibaba.fastjson.JSONObject")) {
				buffer.append("<" + en.getKey() + ">");
				JSONObject jo = jObj.getJSONObject(en.getKey());
				jsonToXmlstr(jo, buffer);
				buffer.append("</" + en.getKey() + ">");
			} else if (en.getValue().getClass().getName().equals("com.alibaba.fastjson.JSONArray")) {
				JSONArray jarray = jObj.getJSONArray(en.getKey());
				for (int i = 0; i < jarray.size(); i++) {
					buffer.append("<" + en.getKey() + ">");
					JSONObject jsonobject = jarray.getJSONObject(i);
					jsonToXmlstr(jsonobject, buffer);
					buffer.append("</" + en.getKey() + ">");
				}
			} else if (en.getValue().getClass().getName().equals("java.lang.String")) {
				buffer.append("<" + en.getKey() + ">" + en.getValue());
				buffer.append("</" + en.getKey() + ">");
			}
		}
		return buffer.toString();
	}

	/**
	 * 将发票JSON格式的转化为对应的发票类型XML格式
	 * @param json
	 * @return
	 * @throws BusinessException
	 */
	public static String hanlerXML(JSONObject json) throws BusinessException {
		String xml = "";
		String xbrlId = json.getString("xbrlId");
		switch (xbrlId) {
			case "inv_spcl_issuer":
				xml = inv_spcl_issuerXML(json); // 增值税电子专用发票
				break;
			case "zjinv_spe_issuer":
				xml = zjinv_spe_issuerXML(json); // 增值税专用发票
				break;
			case "zjinv_odn_issuer":
				xml = zjinv_odn_issuerXML(json); // 增值税普通发票
				break;
			case "inv_ord_issuer":
				xml = inv_ord_issuerXML(json); // 增值税电子普通发票
				break;
			case "inv_tlf_issuer":
				xml = inv_tlf_issuerXML(json); // 收费公路通行费增值税电子普通发票
				break;
			case "zjginv_gen_issuer":
				xml = zjginv_gen_issuerXML(json); // 通用（电子）发票
				break;
			case "zjinv_feord_issuer":
				xml = zjinv_feord_issuerXML(json); // (全电)电子发票(普通发票)
				break;
			case "zjinv_fespcl_issuer":
				xml = zjinv_fespcl_issuerXML(json);// (全电)电子发票(增值税专用发票)
				break;
			default:
				xml = otherXml(json);
		}
		return xml;
	}

	/**
	 * 增值税电子专用发票
	 * 
	 * @param json
	 * @return
	 * @throws BusinessException
	 */
	public static String inv_spcl_issuerXML(JSONObject json) throws BusinessException {
		StringBuilder sbxml = new StringBuilder();
		String xbrlId = json.getString("xbrlId");
		String a = json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller");
		String b = json.getString("NameOfSeller");
		String date = json.getString("DateOfIssue");
		String c = json.getString("UniqueCodeOfInvoice");
		String d = json.getString("xbrlId");
		Object jshjxx = json.get("TaxIncludedAmountInFigures"); // 价税合计（小写）
		Object jshjdx = json.get("TaxIncludedAmountInWords"); // 价税合计（大写）
		Object hj_je = json.get("TotalAmountExcludingTax"); // 合计_金额
		Object hj_se = json.get("TotalTaxAmount"); // 合计_税额
		insertVO(a, b, date, c, d, jshjxx, jshjdx, hj_je, hj_se);
		Object object = json.get("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
		sbxml.append("<xbrl xmlns=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:inv=\"http://xbrl.mof.gov.cn/taxonomy/" + date + "/inv\"");
		sbxml.append("    xmlns:link=\"http://www.xbrl.org/2003/linkbase\"");
		sbxml.append("    xmlns:iso4217=\"http://www.xbrl.org/2003/iso4217\"");
		sbxml.append("    xmlns:xbrli=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
		sbxml.append("    xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
		sbxml.append("	xsi:schemaLocation=\"http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-"
				+ date + ".xsd\">");
		sbxml.append("    <link:schemaRef xlink:type=\"simple\" xlink:href=\"" + xbrlId + "_entry_point_" + date
				+ ".xsd\"/>");
		sbxml.append("    <context id=\"c1\">");
		sbxml.append("        <entity>");
		sbxml.append("            <identifier scheme=\"http://xbrl.mof.gov.cn\">");
		sbxml.append("                <![CDATA[92330483MA2EWR3U6D]]>");
		sbxml.append("            </identifier>");
		sbxml.append("        </entity>");
		sbxml.append("        <period>");
		sbxml.append("            <instant>" + date + "</instant>");
		sbxml.append("        </period>");
		sbxml.append("    </context>");
		sbxml.append("    <unit id=\"u1\">");
		sbxml.append("        <measure>iso4217:CNY</measure>");
		sbxml.append("    </unit>");
		sbxml.append("    <inv:TypeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TypeOfInvoice") + "]]>");
		sbxml.append("    </inv:TypeOfInvoice>");
		sbxml.append("    <inv:UniqueCodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("UniqueCodeOfInvoice") + "]]>");
		sbxml.append("    </inv:UniqueCodeOfInvoice>");
		sbxml.append("    <inv:LocationOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("LocationOfInvoice") + "]]>");
		sbxml.append("    </inv:LocationOfInvoice>");
		sbxml.append("    <inv:CodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("CodeOfInvoice") + "]]>");
		sbxml.append("    </inv:CodeOfInvoice>");
		sbxml.append("    <inv:NumberOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoice") + "]]>");
		sbxml.append("    </inv:NumberOfInvoice>");
		sbxml.append("    <inv:DateOfIssue contextRef=\"c1\">" + date + "</inv:DateOfIssue>");
		sbxml.append("    <inv:IdentifyingCode contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("IdentifyingCode") + "]]>");
		sbxml.append("    </inv:IdentifyingCode>");
		sbxml.append("    <inv:NumberOfInvoiceMachine contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoiceMachine") + "]]>");
		sbxml.append("    </inv:NumberOfInvoiceMachine>");
		sbxml.append("    <inv:SpecialInvoiceType contextRef=\"c1\">" + json.getString("SpecialInvoiceType")
				+ "</inv:SpecialInvoiceType>");
		sbxml.append("    <inv:InvoiceIssuingSign contextRef=\"c1\">" + json.getString("InvoiceIssuingSign")
				+ "</inv:InvoiceIssuingSign>");
		sbxml.append("    <inv:NameOfPurchaser contextRef=\"c1\"> <![CDATA[" + json.getString("NameOfPurchaser")
				+ "]]> </inv:NameOfPurchaser>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser contextRef=\"c1\"> "
				+ " <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser")
				+ "]]> " + "</inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser>");
		sbxml.append("    <inv:AddressPhoneNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("AddressPhoneNumberOfPurchaser") + "</inv:AddressPhoneNumberOfPurchaser>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("DepositBankAndAccountNumberOfPurchaser")
				+ "</inv:DepositBankAndAccountNumberOfPurchaser>");
		sbxml.append("    <inv:TotalAmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalAmountExcludingTax") + "</inv:TotalAmountExcludingTax>");
		sbxml.append("    <inv:TotalTaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalTaxAmount") + "</inv:TotalTaxAmount>");
		sbxml.append("    <inv:TaxIncludedAmountInWords contextRef=\"c1\">  <![CDATA["
				+ json.getString("TaxIncludedAmountInWords") + "]]> </inv:TaxIncludedAmountInWords>");
		sbxml.append("    <inv:TaxIncludedAmountInFigures contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TaxIncludedAmountInFigures") + "</inv:TaxIncludedAmountInFigures>");
		if (object instanceof com.alibaba.fastjson.JSONArray) {
			JSONArray jsonarr = json.getJSONArray("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			for (int i = 0; i < jsonarr.size(); i++) {
				JSONObject item = jsonarr.getJSONObject(i);
				sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
				sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
				sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
				sbxml.append("        </inv:TaxClassificationCode>");
				sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
				sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
				sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
						+ "</inv:Specification>");
				sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
				sbxml.append("        </inv:UnitOfGoodsOrServices>");
				sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
				sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
				sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
				sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
				sbxml.append("        </inv:TaxRate>");
				sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("TaxAmount") + "</inv:TaxAmount>");
				sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			}
		} else {
			JSONObject item = json.getJSONObject("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
			sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
			sbxml.append("        </inv:TaxClassificationCode>");
			sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
			sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
			sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
					+ "</inv:Specification>");
			sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
			sbxml.append("        </inv:UnitOfGoodsOrServices>");
			sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
			sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
			sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
			sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
			sbxml.append("        </inv:TaxRate>");
			sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("TaxAmount") + "</inv:TaxAmount>");
			sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");

		}
		sbxml.append("    <inv:NameOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NameOfSeller") + "]]>");
		sbxml.append("    </inv:NameOfSeller>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller")
				+ "]]>");
		sbxml.append("    </inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller>");
		sbxml.append("    <inv:AddressPhoneNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("AddressPhoneNumberOfSeller") + "]]>");
		sbxml.append("    </inv:AddressPhoneNumberOfSeller>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("DepositBankAndAccountNumberOfSeller") + "]]>");
		sbxml.append("    </inv:DepositBankAndAccountNumberOfSeller>");
		sbxml.append("    <inv:Remarks contextRef=\"c1\">" + json.getString("Remarks") + "</inv:Remarks>");
		sbxml.append("    <inv:Payee contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Payee") + "]]>");
		sbxml.append("    </inv:Payee>");
		sbxml.append("    <inv:Reviewer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Reviewer") + "]]>");
		sbxml.append("    </inv:Reviewer>");
		sbxml.append("    <inv:Issuer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Issuer") + "]]>");
		sbxml.append("    </inv:Issuer>");
		sbxml.append("    <inv:BeginningOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("BeginningOfIncomePeriodUnderAccrualBasis")
				+ "</inv:BeginningOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("    <inv:EndOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("EndOfIncomePeriodUnderAccrualBasis") + "</inv:EndOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("</xbrl>");
		return sbxml.toString();

	}

	/**
	 * 增值税普通发票
	 * 
	 * @param json
	 * @return
	 * @throws BusinessException
	 */
	public static String zjinv_odn_issuerXML(JSONObject json) throws BusinessException {
		StringBuilder sbxml = new StringBuilder();
		String xbrlId = json.getString("xbrlId");
		String a = json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller");
		String b = json.getString("NameOfSeller");
		String date = json.getString("DateOfIssue");
		String c = json.getString("UniqueCodeOfInvoice");
		String d = json.getString("xbrlId");
		Object jshjxx = json.get("TaxIncludedAmountInFigures"); // 价税合计（小写）
		Object jshjdx = json.get("TaxIncludedAmountInWords"); // 价税合计（大写）
		Object hj_je = json.get("TotalAmountExcludingTax"); // 合计_金额
		Object hj_se = json.get("TotalTaxAmount"); // 合计_税额
		insertVO(a, b, date, c, d, jshjxx, jshjdx, hj_je, hj_se);
		Object object = json.get("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
		sbxml.append("<xbrl xmlns=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:inv=\"http://xbrl.mof.gov.cn/taxonomy/" + date + "/inv\"");
		sbxml.append("    xmlns:link=\"http://www.xbrl.org/2003/linkbase\"");
		sbxml.append("    xmlns:iso4217=\"http://www.xbrl.org/2003/iso4217\"");
		sbxml.append("    xmlns:xbrli=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
		sbxml.append("    xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
		sbxml.append("	xsi:schemaLocation=\"http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-"
				+ date + ".xsd\">");
		sbxml.append("    <link:schemaRef xlink:type=\"simple\" xlink:href=\"" + xbrlId + "_entry_point_" + date
				+ ".xsd\"/>");
		sbxml.append("    <context id=\"c1\">");
		sbxml.append("        <entity>");
		sbxml.append("            <identifier scheme=\"http://xbrl.mof.gov.cn\">");
		sbxml.append("                <![CDATA[92330483MA2EWR3U6D]]>");
		sbxml.append("            </identifier>");
		sbxml.append("        </entity>");
		sbxml.append("        <period>");
		sbxml.append("            <instant>" + date + "</instant>");
		sbxml.append("        </period>");
		sbxml.append("    </context>");
		sbxml.append("    <unit id=\"u1\">");
		sbxml.append("        <measure>iso4217:CNY</measure>");
		sbxml.append("    </unit>");
		sbxml.append("    <inv:TypeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TypeOfInvoice") + "]]>");
		sbxml.append("    </inv:TypeOfInvoice>");
		sbxml.append("    <inv:UniqueCodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("UniqueCodeOfInvoice") + "]]>");
		sbxml.append("    </inv:UniqueCodeOfInvoice>");
		sbxml.append("    <inv:LocationOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("LocationOfInvoice") + "]]>");
		sbxml.append("    </inv:LocationOfInvoice>");
		sbxml.append("    <inv:CodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("CodeOfInvoice") + "]]>");
		sbxml.append("    </inv:CodeOfInvoice>");
		sbxml.append("    <inv:NumberOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoice") + "]]>");
		sbxml.append("    </inv:NumberOfInvoice>");
		sbxml.append("    <inv:DateOfIssue contextRef=\"c1\">" + date + "</inv:DateOfIssue>");
		sbxml.append("    <inv:IdentifyingCode contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("IdentifyingCode") + "]]>");
		sbxml.append("    </inv:IdentifyingCode>");
		sbxml.append("    <inv:NumberOfInvoiceMachine contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoiceMachine") + "]]>");
		sbxml.append("    </inv:NumberOfInvoiceMachine>");
		sbxml.append("    <inv:SpecialInvoiceType contextRef=\"c1\">" + json.getString("SpecialInvoiceType")
				+ "</inv:SpecialInvoiceType>");
		sbxml.append("    <inv:InvoiceIssuingSign contextRef=\"c1\">" + json.getString("InvoiceIssuingSign")
				+ "</inv:InvoiceIssuingSign>");
		sbxml.append("    <inv:NameOfPurchaser contextRef=\"c1\"> <![CDATA[" + json.getString("NameOfPurchaser")
				+ "]]> </inv:NameOfPurchaser>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser contextRef=\"c1\"> "
				+ " <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser")
				+ "]]> " + "</inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser>");
		sbxml.append("    <inv:AddressPhoneNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("AddressPhoneNumberOfPurchaser") + "</inv:AddressPhoneNumberOfPurchaser>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("DepositBankAndAccountNumberOfPurchaser")
				+ "</inv:DepositBankAndAccountNumberOfPurchaser>");
		sbxml.append("    <inv:TotalAmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalAmountExcludingTax") + "</inv:TotalAmountExcludingTax>");
		sbxml.append("    <inv:TotalTaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalTaxAmount") + "</inv:TotalTaxAmount>");
		sbxml.append("    <inv:TaxIncludedAmountInWords contextRef=\"c1\">  <![CDATA["
				+ json.getString("TaxIncludedAmountInWords") + "]]> </inv:TaxIncludedAmountInWords>");
		sbxml.append("    <inv:TaxIncludedAmountInFigures contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TaxIncludedAmountInFigures") + "</inv:TaxIncludedAmountInFigures>");
		if (object instanceof com.alibaba.fastjson.JSONArray) {
			JSONArray jsonarr = json.getJSONArray("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			for (int i = 0; i < jsonarr.size(); i++) {
				JSONObject item = jsonarr.getJSONObject(i);
				sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
				sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
				sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
				sbxml.append("        </inv:TaxClassificationCode>");
				sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
				sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
				sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
						+ "</inv:Specification>");
				sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
				sbxml.append("        </inv:UnitOfGoodsOrServices>");
				sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
				sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
				sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
				sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
				sbxml.append("        </inv:TaxRate>");
				sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("TaxAmount") + "</inv:TaxAmount>");
				sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			}
		} else {
			JSONObject item = json.getJSONObject("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
			sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
			sbxml.append("        </inv:TaxClassificationCode>");
			sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
			sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
			sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
					+ "</inv:Specification>");
			sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
			sbxml.append("        </inv:UnitOfGoodsOrServices>");
			sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
			sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
			sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
			sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
			sbxml.append("        </inv:TaxRate>");
			sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("TaxAmount") + "</inv:TaxAmount>");
			sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");

		}
		sbxml.append("    <inv:NameOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NameOfSeller") + "]]>");
		sbxml.append("    </inv:NameOfSeller>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller")
				+ "]]>");
		sbxml.append("    </inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller>");
		sbxml.append("    <inv:AddressPhoneNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("AddressPhoneNumberOfSeller") + "]]>");
		sbxml.append("    </inv:AddressPhoneNumberOfSeller>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("DepositBankAndAccountNumberOfSeller") + "]]>");
		sbxml.append("    </inv:DepositBankAndAccountNumberOfSeller>");
		sbxml.append("    <inv:Remarks contextRef=\"c1\">" + json.getString("Remarks") + "</inv:Remarks>");
		sbxml.append("    <inv:Payee contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Payee") + "]]>");
		sbxml.append("    </inv:Payee>");
		sbxml.append("    <inv:Reviewer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Reviewer") + "]]>");
		sbxml.append("    </inv:Reviewer>");
		sbxml.append("    <inv:Issuer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Issuer") + "]]>");
		sbxml.append("    </inv:Issuer>");
		sbxml.append("    <inv:BeginningOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("BeginningOfIncomePeriodUnderAccrualBasis")
				+ "</inv:BeginningOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("    <inv:EndOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("EndOfIncomePeriodUnderAccrualBasis") + "</inv:EndOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("</xbrl>");
		return sbxml.toString();

	}

	/**
	 * 增值税电子普通发票
	 * 
	 * @param json
	 * @return
	 * @throws BusinessException
	 */
	public static String inv_ord_issuerXML(JSONObject json) throws BusinessException {
		StringBuilder sbxml = new StringBuilder();
		String xbrlId = json.getString("xbrlId");
		String a = json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller");
		String b = json.getString("NameOfSeller");
		String date = json.getString("DateOfIssue");
		String c = json.getString("UniqueCodeOfInvoice");
		String d = json.getString("xbrlId");
		Object jshjxx = json.get("TaxIncludedAmountInFigures"); // 价税合计（小写）
		Object jshjdx = json.get("TaxIncludedAmountInWords"); // 价税合计（大写）
		Object hj_je = json.get("TotalAmountExcludingTax"); // 合计_金额
		Object hj_se = json.get("TotalTaxAmount"); // 合计_税额
		insertVO(a, b, date, c, d, jshjxx, jshjdx, hj_je, hj_se);
		Object object = json.get("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
		sbxml.append("<xbrl xmlns=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:inv=\"http://xbrl.mof.gov.cn/taxonomy/" + date + "/inv\"");
		sbxml.append("    xmlns:link=\"http://www.xbrl.org/2003/linkbase\"");
		sbxml.append("    xmlns:iso4217=\"http://www.xbrl.org/2003/iso4217\"");
		sbxml.append("    xmlns:xbrli=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
		sbxml.append("    xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
		sbxml.append("	xsi:schemaLocation=\"http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-"
				+ date + ".xsd\">");
		sbxml.append("    <link:schemaRef xlink:type=\"simple\" xlink:href=\"" + xbrlId + "_entry_point_" + date
				+ ".xsd\"/>");
		sbxml.append("    <context id=\"c1\">");
		sbxml.append("        <entity>");
		sbxml.append("            <identifier scheme=\"http://xbrl.mof.gov.cn\">");
		sbxml.append("                <![CDATA[92330483MA2EWR3U6D]]>");
		sbxml.append("            </identifier>");
		sbxml.append("        </entity>");
		sbxml.append("        <period>");
		sbxml.append("            <instant>" + date + "</instant>");
		sbxml.append("        </period>");
		sbxml.append("    </context>");
		sbxml.append("    <unit id=\"u1\">");
		sbxml.append("        <measure>iso4217:CNY</measure>");
		sbxml.append("    </unit>");
		sbxml.append("    <inv:TypeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TypeOfInvoice") + "]]>");
		sbxml.append("    </inv:TypeOfInvoice>");
		sbxml.append("    <inv:UniqueCodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("UniqueCodeOfInvoice") + "]]>");
		sbxml.append("    </inv:UniqueCodeOfInvoice>");
		sbxml.append("    <inv:LocationOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("LocationOfInvoice") + "]]>");
		sbxml.append("    </inv:LocationOfInvoice>");
		sbxml.append("    <inv:CodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("CodeOfInvoice") + "]]>");
		sbxml.append("    </inv:CodeOfInvoice>");
		sbxml.append("    <inv:NumberOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoice") + "]]>");
		sbxml.append("    </inv:NumberOfInvoice>");
		sbxml.append("    <inv:DateOfIssue contextRef=\"c1\">" + date + "</inv:DateOfIssue>");
		sbxml.append("    <inv:IdentifyingCode contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("IdentifyingCode") + "]]>");
		sbxml.append("    </inv:IdentifyingCode>");
		sbxml.append("    <inv:NumberOfInvoiceMachine contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoiceMachine") + "]]>");
		sbxml.append("    </inv:NumberOfInvoiceMachine>");
		sbxml.append("    <inv:SpecialInvoiceType contextRef=\"c1\">" + json.getString("SpecialInvoiceType")
				+ "</inv:SpecialInvoiceType>");
		sbxml.append("    <inv:InvoiceIssuingSign contextRef=\"c1\">" + json.getString("InvoiceIssuingSign")
				+ "</inv:InvoiceIssuingSign>");
		sbxml.append("    <inv:NameOfPurchaser contextRef=\"c1\"> <![CDATA[" + json.getString("NameOfPurchaser")
				+ "]]> </inv:NameOfPurchaser>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser contextRef=\"c1\"> "
				+ " <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser")
				+ "]]> " + "</inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser>");
		sbxml.append("    <inv:AddressPhoneNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("AddressPhoneNumberOfPurchaser") + "</inv:AddressPhoneNumberOfPurchaser>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("DepositBankAndAccountNumberOfPurchaser")
				+ "</inv:DepositBankAndAccountNumberOfPurchaser>");
		sbxml.append("    <inv:TotalAmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalAmountExcludingTax") + "</inv:TotalAmountExcludingTax>");
		sbxml.append("    <inv:TotalTaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalTaxAmount") + "</inv:TotalTaxAmount>");
		sbxml.append("    <inv:TaxIncludedAmountInWords contextRef=\"c1\">  <![CDATA["
				+ json.getString("TaxIncludedAmountInWords") + "]]> </inv:TaxIncludedAmountInWords>");
		sbxml.append("    <inv:TaxIncludedAmountInFigures contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TaxIncludedAmountInFigures") + "</inv:TaxIncludedAmountInFigures>");
		if (object instanceof com.alibaba.fastjson.JSONArray) {
			JSONArray jsonarr = json.getJSONArray("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			for (int i = 0; i < jsonarr.size(); i++) {
				JSONObject item = jsonarr.getJSONObject(i);
				sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
				sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
				sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
				sbxml.append("        </inv:TaxClassificationCode>");
				sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
				sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
				sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
						+ "</inv:Specification>");
				sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
				sbxml.append("        </inv:UnitOfGoodsOrServices>");
				sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
				sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
				sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
				sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
				sbxml.append("        </inv:TaxRate>");
				sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("TaxAmount") + "</inv:TaxAmount>");
				sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			}
		} else {
			JSONObject item = json.getJSONObject("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
			sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
			sbxml.append("        </inv:TaxClassificationCode>");
			sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
			sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
			sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
					+ "</inv:Specification>");
			sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
			sbxml.append("        </inv:UnitOfGoodsOrServices>");
			sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
			sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
			sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
			sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
			sbxml.append("        </inv:TaxRate>");
			sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("TaxAmount") + "</inv:TaxAmount>");
			sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");

		}
		sbxml.append("    <inv:NameOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NameOfSeller") + "]]>");
		sbxml.append("    </inv:NameOfSeller>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller")
				+ "]]>");
		sbxml.append("    </inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller>");
		sbxml.append("    <inv:AddressPhoneNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("AddressPhoneNumberOfSeller") + "]]>");
		sbxml.append("    </inv:AddressPhoneNumberOfSeller>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("DepositBankAndAccountNumberOfSeller") + "]]>");
		sbxml.append("    </inv:DepositBankAndAccountNumberOfSeller>");
		sbxml.append("    <inv:Remarks contextRef=\"c1\">" + json.getString("Remarks") + "</inv:Remarks>");
		sbxml.append("    <inv:Payee contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Payee") + "]]>");
		sbxml.append("    </inv:Payee>");
		sbxml.append("    <inv:Reviewer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Reviewer") + "]]>");
		sbxml.append("    </inv:Reviewer>");
		sbxml.append("    <inv:Issuer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Issuer") + "]]>");
		sbxml.append("    </inv:Issuer>");
		sbxml.append("    <inv:BeginningOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("BeginningOfIncomePeriodUnderAccrualBasis")
				+ "</inv:BeginningOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("    <inv:EndOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("EndOfIncomePeriodUnderAccrualBasis") + "</inv:EndOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("</xbrl>");
		return sbxml.toString();
	}

	/**
	 * 增值税专用发票
	 * 
	 * @param json
	 * @return
	 * @throws BusinessException
	 */
	public static String zjinv_spe_issuerXML(JSONObject json) throws BusinessException {
		StringBuilder sbxml = new StringBuilder();
		String xbrlId = json.getString("xbrlId");
		String a = json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller");
		String b = json.getString("NameOfSeller");
		String date = json.getString("DateOfIssue");
		String c = json.getString("UniqueCodeOfInvoice");
		String d = json.getString("xbrlId");
		Object jshjxx = json.get("TaxIncludedAmountInFigures"); // 价税合计（小写）
		Object jshjdx = json.get("TaxIncludedAmountInWords"); // 价税合计（大写）
		Object hj_je = json.get("TotalAmountExcludingTax"); // 合计_金额
		Object hj_se = json.get("TotalTaxAmount"); // 合计_税额
		insertVO(a, b, date, c, d, jshjxx, jshjdx, hj_je, hj_se);
		Object object = json.get("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
		sbxml.append("<xbrl xmlns=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:inv=\"http://xbrl.mof.gov.cn/taxonomy/" + date + "/inv\"");
		sbxml.append("    xmlns:link=\"http://www.xbrl.org/2003/linkbase\"");
		sbxml.append("    xmlns:iso4217=\"http://www.xbrl.org/2003/iso4217\"");
		sbxml.append("    xmlns:xbrli=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
		sbxml.append("    xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
		sbxml.append("	xsi:schemaLocation=\"http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-"
				+ date + ".xsd\">");
		sbxml.append("    <link:schemaRef xlink:type=\"simple\" xlink:href=\"" + xbrlId + "_entry_point_" + date
				+ ".xsd\"/>");
		sbxml.append("    <context id=\"c1\">");
		sbxml.append("        <entity>");
		sbxml.append("            <identifier scheme=\"http://xbrl.mof.gov.cn\">");
		sbxml.append("                <![CDATA[92330483MA2EWR3U6D]]>");
		sbxml.append("            </identifier>");
		sbxml.append("        </entity>");
		sbxml.append("        <period>");
		sbxml.append("            <instant>" + date + "</instant>");
		sbxml.append("        </period>");
		sbxml.append("    </context>");
		sbxml.append("    <unit id=\"u1\">");
		sbxml.append("        <measure>iso4217:CNY</measure>");
		sbxml.append("    </unit>");
		sbxml.append("    <inv:TypeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TypeOfInvoice") + "]]>");
		sbxml.append("    </inv:TypeOfInvoice>");
		sbxml.append("    <inv:UniqueCodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("UniqueCodeOfInvoice") + "]]>");
		sbxml.append("    </inv:UniqueCodeOfInvoice>");
		sbxml.append("    <inv:LocationOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("LocationOfInvoice") + "]]>");
		sbxml.append("    </inv:LocationOfInvoice>");
		sbxml.append("    <inv:CodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("CodeOfInvoice") + "]]>");
		sbxml.append("    </inv:CodeOfInvoice>");
		sbxml.append("    <inv:NumberOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoice") + "]]>");
		sbxml.append("    </inv:NumberOfInvoice>");
		sbxml.append("    <inv:DateOfIssue contextRef=\"c1\">" + date + "</inv:DateOfIssue>");
		sbxml.append("    <inv:IdentifyingCode contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("IdentifyingCode") + "]]>");
		sbxml.append("    </inv:IdentifyingCode>");
		sbxml.append("    <inv:NumberOfInvoiceMachine contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoiceMachine") + "]]>");
		sbxml.append("    </inv:NumberOfInvoiceMachine>");
		sbxml.append("    <inv:SpecialInvoiceType contextRef=\"c1\">" + json.getString("SpecialInvoiceType")
				+ "</inv:SpecialInvoiceType>");
		sbxml.append("    <inv:InvoiceIssuingSign contextRef=\"c1\">" + json.getString("InvoiceIssuingSign")
				+ "</inv:InvoiceIssuingSign>");
		sbxml.append("    <inv:NameOfPurchaser contextRef=\"c1\"> <![CDATA[" + json.getString("NameOfPurchaser")
				+ "]]> </inv:NameOfPurchaser>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser contextRef=\"c1\"> "
				+ " <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser")
				+ "]]> " + "</inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser>");
		sbxml.append("    <inv:AddressPhoneNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("AddressPhoneNumberOfPurchaser") + "</inv:AddressPhoneNumberOfPurchaser>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("DepositBankAndAccountNumberOfPurchaser")
				+ "</inv:DepositBankAndAccountNumberOfPurchaser>");
		sbxml.append("    <inv:TotalAmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalAmountExcludingTax") + "</inv:TotalAmountExcludingTax>");
		sbxml.append("    <inv:TotalTaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalTaxAmount") + "</inv:TotalTaxAmount>");
		sbxml.append("    <inv:TaxIncludedAmountInWords contextRef=\"c1\">  <![CDATA["
				+ json.getString("TaxIncludedAmountInWords") + "]]> </inv:TaxIncludedAmountInWords>");
		sbxml.append("    <inv:TaxIncludedAmountInFigures contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TaxIncludedAmountInFigures") + "</inv:TaxIncludedAmountInFigures>");
		if (object instanceof com.alibaba.fastjson.JSONArray) {
			JSONArray jsonarr = json.getJSONArray("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			for (int i = 0; i < jsonarr.size(); i++) {
				JSONObject item = jsonarr.getJSONObject(i);
				sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
				sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
				sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
				sbxml.append("        </inv:TaxClassificationCode>");
				sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
				sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
				sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
						+ "</inv:Specification>");
				sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
				sbxml.append("        </inv:UnitOfGoodsOrServices>");
				sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
				sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
				sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
				sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
				sbxml.append("        </inv:TaxRate>");
				sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("TaxAmount") + "</inv:TaxAmount>");
				sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			}
		} else {
			JSONObject item = json.getJSONObject("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
			sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
			sbxml.append("        </inv:TaxClassificationCode>");
			sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
			sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
			sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
					+ "</inv:Specification>");
			sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
			sbxml.append("        </inv:UnitOfGoodsOrServices>");
			sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
			sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
			sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
			sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
			sbxml.append("        </inv:TaxRate>");
			sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("TaxAmount") + "</inv:TaxAmount>");
			sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");

		}
		sbxml.append("    <inv:NameOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NameOfSeller") + "]]>");
		sbxml.append("    </inv:NameOfSeller>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller")
				+ "]]>");
		sbxml.append("    </inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller>");
		sbxml.append("    <inv:AddressPhoneNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("AddressPhoneNumberOfSeller") + "]]>");
		sbxml.append("    </inv:AddressPhoneNumberOfSeller>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("DepositBankAndAccountNumberOfSeller") + "]]>");
		sbxml.append("    </inv:DepositBankAndAccountNumberOfSeller>");
		sbxml.append("    <inv:Remarks contextRef=\"c1\">" + json.getString("Remarks") + "</inv:Remarks>");
		sbxml.append("    <inv:Payee contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Payee") + "]]>");
		sbxml.append("    </inv:Payee>");
		sbxml.append("    <inv:Reviewer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Reviewer") + "]]>");
		sbxml.append("    </inv:Reviewer>");
		sbxml.append("    <inv:Issuer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Issuer") + "]]>");
		sbxml.append("    </inv:Issuer>");
		sbxml.append("    <inv:BeginningOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("BeginningOfIncomePeriodUnderAccrualBasis")
				+ "</inv:BeginningOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("    <inv:EndOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("EndOfIncomePeriodUnderAccrualBasis") + "</inv:EndOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("</xbrl>");
		return sbxml.toString();

	}

	/**
	 * 通用（电子）发票
	 * 
	 * @param json
	 * @return
	 * @throws BusinessException
	 */
	public static String zjginv_gen_issuerXML(JSONObject json) throws BusinessException {
		StringBuilder sbxml = new StringBuilder();
		String xbrlId = json.getString("xbrlId");
		String a = json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller");
		String b = json.getString("NameOfSeller");
		String date = json.getString("DateOfIssue");
		String c = json.getString("UniqueCodeOfInvoice");
		String d = json.getString("xbrlId");
		Object jshjxx = json.get("TaxIncludedAmountInFigures"); // 价税合计（小写）
		Object jshjdx = json.get("TaxIncludedAmountInWords"); // 价税合计（大写）
		Object hj_je = json.get("TotalAmountExcludingTax"); // 合计_金额
		Object hj_se = json.get("TotalTaxAmount"); // 合计_税额
		insertVO(a, b, date, c, d, jshjxx, jshjdx, hj_je, hj_se);
		Object object = json.get("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
		sbxml.append("<xbrl xmlns=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:inv=\"http://xbrl.mof.gov.cn/taxonomy/" + date + "/inv\"");
		sbxml.append("    xmlns:link=\"http://www.xbrl.org/2003/linkbase\"");
		sbxml.append("    xmlns:iso4217=\"http://www.xbrl.org/2003/iso4217\"");
		sbxml.append("    xmlns:xbrli=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
		sbxml.append("    xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
		sbxml.append("	xsi:schemaLocation=\"http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-"
				+ date + ".xsd\">");
		sbxml.append("    <link:schemaRef xlink:type=\"simple\" xlink:href=\"" + xbrlId + "_entry_point_" + date
				+ ".xsd\"/>");
		sbxml.append("    <context id=\"c1\">");
		sbxml.append("        <entity>");
		sbxml.append("            <identifier scheme=\"http://xbrl.mof.gov.cn\">");
		sbxml.append("                <![CDATA[92330483MA2EWR3U6D]]>");
		sbxml.append("            </identifier>");
		sbxml.append("        </entity>");
		sbxml.append("        <period>");
		sbxml.append("            <instant>" + date + "</instant>");
		sbxml.append("        </period>");
		sbxml.append("    </context>");
		sbxml.append("    <unit id=\"u1\">");
		sbxml.append("        <measure>iso4217:CNY</measure>");
		sbxml.append("    </unit>");
		sbxml.append("    <inv:TypeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TypeOfInvoice") + "]]>");
		sbxml.append("    </inv:TypeOfInvoice>");
		sbxml.append("    <inv:UniqueCodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("UniqueCodeOfInvoice") + "]]>");
		sbxml.append("    </inv:UniqueCodeOfInvoice>");
		sbxml.append("    <inv:LocationOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("LocationOfInvoice") + "]]>");
		sbxml.append("    </inv:LocationOfInvoice>");
		sbxml.append("    <inv:CodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("CodeOfInvoice") + "]]>");
		sbxml.append("    </inv:CodeOfInvoice>");
		sbxml.append("    <inv:NumberOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoice") + "]]>");
		sbxml.append("    </inv:NumberOfInvoice>");
		sbxml.append("    <inv:DateOfIssue contextRef=\"c1\">" + date + "</inv:DateOfIssue>");
		sbxml.append("    <inv:IdentifyingCode contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("IdentifyingCode") + "]]>");
		sbxml.append("    </inv:IdentifyingCode>");
		sbxml.append("    <inv:NumberOfInvoiceMachine contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoiceMachine") + "]]>");
		sbxml.append("    </inv:NumberOfInvoiceMachine>");
		sbxml.append("    <inv:SpecialInvoiceType contextRef=\"c1\">" + json.getString("SpecialInvoiceType")
				+ "</inv:SpecialInvoiceType>");
		sbxml.append("    <inv:InvoiceIssuingSign contextRef=\"c1\">" + json.getString("InvoiceIssuingSign")
				+ "</inv:InvoiceIssuingSign>");
		sbxml.append("    <inv:NameOfPurchaser contextRef=\"c1\"> <![CDATA[" + json.getString("NameOfPurchaser")
				+ "]]> </inv:NameOfPurchaser>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser contextRef=\"c1\"> "
				+ " <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser")
				+ "]]> " + "</inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser>");
		sbxml.append("    <inv:AddressPhoneNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("AddressPhoneNumberOfPurchaser") + "</inv:AddressPhoneNumberOfPurchaser>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("DepositBankAndAccountNumberOfPurchaser")
				+ "</inv:DepositBankAndAccountNumberOfPurchaser>");
		sbxml.append("    <inv:TotalAmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalAmountExcludingTax") + "</inv:TotalAmountExcludingTax>");
		sbxml.append("    <inv:TotalTaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalTaxAmount") + "</inv:TotalTaxAmount>");
		sbxml.append("    <inv:TaxIncludedAmountInWords contextRef=\"c1\">  <![CDATA["
				+ json.getString("TaxIncludedAmountInWords") + "]]> </inv:TaxIncludedAmountInWords>");
		sbxml.append("    <inv:TaxIncludedAmountInFigures contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TaxIncludedAmountInFigures") + "</inv:TaxIncludedAmountInFigures>");
		if (object instanceof com.alibaba.fastjson.JSONArray) {
			JSONArray jsonarr = json.getJSONArray("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			for (int i = 0; i < jsonarr.size(); i++) {
				JSONObject item = jsonarr.getJSONObject(i);
				sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
				sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
				sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
				sbxml.append("        </inv:TaxClassificationCode>");
				sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
				sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
				sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
						+ "</inv:Specification>");
				sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
				sbxml.append("        </inv:UnitOfGoodsOrServices>");
				sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
				sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
				sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
				sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
				sbxml.append("        </inv:TaxRate>");
				sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("TaxAmount") + "</inv:TaxAmount>");
				sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			}
		} else {
			JSONObject item = json.getJSONObject("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
			sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
			sbxml.append("        </inv:TaxClassificationCode>");
			sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
			sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
			sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
					+ "</inv:Specification>");
			sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
			sbxml.append("        </inv:UnitOfGoodsOrServices>");
			sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
			sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
			sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
			sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
			sbxml.append("        </inv:TaxRate>");
			sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("TaxAmount") + "</inv:TaxAmount>");
			sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");

		}
		sbxml.append("    <inv:NameOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NameOfSeller") + "]]>");
		sbxml.append("    </inv:NameOfSeller>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller")
				+ "]]>");
		sbxml.append("    </inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller>");
		sbxml.append("    <inv:AddressPhoneNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("AddressPhoneNumberOfSeller") + "]]>");
		sbxml.append("    </inv:AddressPhoneNumberOfSeller>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("DepositBankAndAccountNumberOfSeller") + "]]>");
		sbxml.append("    </inv:DepositBankAndAccountNumberOfSeller>");
		sbxml.append("    <inv:Remarks contextRef=\"c1\">" + json.getString("Remarks") + "</inv:Remarks>");
		sbxml.append("    <inv:Payee contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Payee") + "]]>");
		sbxml.append("    </inv:Payee>");
		sbxml.append("    <inv:Reviewer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Reviewer") + "]]>");
		sbxml.append("    </inv:Reviewer>");
		sbxml.append("    <inv:Issuer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Issuer") + "]]>");
		sbxml.append("    </inv:Issuer>");
		sbxml.append("    <inv:BeginningOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("BeginningOfIncomePeriodUnderAccrualBasis")
				+ "</inv:BeginningOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("    <inv:EndOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("EndOfIncomePeriodUnderAccrualBasis") + "</inv:EndOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("</xbrl>");
		return sbxml.toString();

	}
	
	/**
	 * 收费公路通行费增值税电子普通发票
	 * @param json
	 * @return
	 * @throws BusinessException
	 */
	public static String inv_tlf_issuerXML(JSONObject json) throws BusinessException {
		StringBuilder sbxml = new StringBuilder();
		String xbrlId = json.getString("xbrlId");
		String a = json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller");
		String b = json.getString("NameOfSeller");
		String date = json.getString("DateOfIssue");
		String c = json.getString("UniqueCodeOfInvoice");
		String d = json.getString("xbrlId");
		Object jshjxx = json.get("TaxIncludedAmountInFigures"); // 价税合计（小写）
		Object jshjdx = json.get("TaxIncludedAmountInWords"); // 价税合计（大写）
		Object hj_je = json.get("TotalAmountExcludingTax"); // 合计_金额
		Object hj_se = json.get("TotalTaxAmount"); // 合计_税额
		insertVO(a, b, date, c, d, jshjxx, jshjdx, hj_je, hj_se);
		Object object = json.get("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
		sbxml.append("<xbrl xmlns=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:inv=\"http://xbrl.mof.gov.cn/taxonomy/" + date + "/inv\"");
		sbxml.append("    xmlns:link=\"http://www.xbrl.org/2003/linkbase\"");
		sbxml.append("    xmlns:iso4217=\"http://www.xbrl.org/2003/iso4217\"");
		sbxml.append("    xmlns:xbrli=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
		sbxml.append("    xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
		sbxml.append("	xsi:schemaLocation=\"http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-"
				+ date + ".xsd\">");
		sbxml.append("    <link:schemaRef xlink:type=\"simple\" xlink:href=\"" + xbrlId + "_entry_point_" + date
				+ ".xsd\"/>");
		sbxml.append("    <context id=\"c1\">");
		sbxml.append("        <entity>");
		sbxml.append("            <identifier scheme=\"http://xbrl.mof.gov.cn\">");
		sbxml.append("                <![CDATA[92330483MA2EWR3U6D]]>");
		sbxml.append("            </identifier>");
		sbxml.append("        </entity>");
		sbxml.append("        <period>");
		sbxml.append("            <instant>" + date + "</instant>");
		sbxml.append("        </period>");
		sbxml.append("    </context>");
		sbxml.append("    <unit id=\"u1\">");
		sbxml.append("        <measure>iso4217:CNY</measure>");
		sbxml.append("    </unit>");
		sbxml.append("    <inv:TypeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TypeOfInvoice") + "]]>");
		sbxml.append("    </inv:TypeOfInvoice>");
		sbxml.append("    <inv:UniqueCodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("UniqueCodeOfInvoice") + "]]>");
		sbxml.append("    </inv:UniqueCodeOfInvoice>");
		sbxml.append("    <inv:LocationOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("LocationOfInvoice") + "]]>");
		sbxml.append("    </inv:LocationOfInvoice>");
		sbxml.append("    <inv:CodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("CodeOfInvoice") + "]]>");
		sbxml.append("    </inv:CodeOfInvoice>");
		sbxml.append("    <inv:NumberOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoice") + "]]>");
		sbxml.append("    </inv:NumberOfInvoice>");
		sbxml.append("    <inv:DateOfIssue contextRef=\"c1\">" + date + "</inv:DateOfIssue>");
		sbxml.append("    <inv:IdentifyingCode contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("IdentifyingCode") + "]]>");
		sbxml.append("    </inv:IdentifyingCode>");
		sbxml.append("    <inv:NumberOfInvoiceMachine contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoiceMachine") + "]]>");
		sbxml.append("    </inv:NumberOfInvoiceMachine>");
		sbxml.append("    <inv:SpecialInvoiceType contextRef=\"c1\">" + json.getString("SpecialInvoiceType")
				+ "</inv:SpecialInvoiceType>");
		sbxml.append("    <inv:InvoiceIssuingSign contextRef=\"c1\">" + json.getString("InvoiceIssuingSign")
				+ "</inv:InvoiceIssuingSign>");
		sbxml.append("    <inv:NameOfPurchaser contextRef=\"c1\"> <![CDATA[" + json.getString("NameOfPurchaser")
				+ "]]> </inv:NameOfPurchaser>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser contextRef=\"c1\"> "
				+ " <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser")
				+ "]]> " + "</inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser>");
		sbxml.append("    <inv:AddressPhoneNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("AddressPhoneNumberOfPurchaser") + "</inv:AddressPhoneNumberOfPurchaser>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("DepositBankAndAccountNumberOfPurchaser")
				+ "</inv:DepositBankAndAccountNumberOfPurchaser>");
		sbxml.append("    <inv:TotalAmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalAmountExcludingTax") + "</inv:TotalAmountExcludingTax>");
		sbxml.append("    <inv:TotalTaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalTaxAmount") + "</inv:TotalTaxAmount>");
		sbxml.append("    <inv:TaxIncludedAmountInWords contextRef=\"c1\">  <![CDATA["
				+ json.getString("TaxIncludedAmountInWords") + "]]> </inv:TaxIncludedAmountInWords>");
		sbxml.append("    <inv:TaxIncludedAmountInFigures contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TaxIncludedAmountInFigures") + "</inv:TaxIncludedAmountInFigures>");
		if (object instanceof com.alibaba.fastjson.JSONArray) {
			JSONArray jsonarr = json.getJSONArray("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			for (int i = 0; i < jsonarr.size(); i++) {
				JSONObject item = jsonarr.getJSONObject(i);
				sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
				sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
				sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
				sbxml.append("        </inv:TaxClassificationCode>");
				sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
				sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
				sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
						+ "</inv:Specification>");
				sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
				sbxml.append("        </inv:UnitOfGoodsOrServices>");
				sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
				sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
				sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
				sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
				sbxml.append("        </inv:TaxRate>");
				sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("TaxAmount") + "</inv:TaxAmount>");
				sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			}
		}else if(object == null) {
			
		} else {
			JSONObject item = json.getJSONObject("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
			sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
			sbxml.append("        </inv:TaxClassificationCode>");
			sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
			sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
			sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
					+ "</inv:Specification>");
			sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
			sbxml.append("        </inv:UnitOfGoodsOrServices>");
			sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
			sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
			sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
			sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
			sbxml.append("        </inv:TaxRate>");
			sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("TaxAmount") + "</inv:TaxAmount>");
			sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");

		}
		sbxml.append("    <inv:NameOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NameOfSeller") + "]]>");
		sbxml.append("    </inv:NameOfSeller>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller")
				+ "]]>");
		sbxml.append("    </inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller>");
		sbxml.append("    <inv:AddressPhoneNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("AddressPhoneNumberOfSeller") + "]]>");
		sbxml.append("    </inv:AddressPhoneNumberOfSeller>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("DepositBankAndAccountNumberOfSeller") + "]]>");
		sbxml.append("    </inv:DepositBankAndAccountNumberOfSeller>");
		sbxml.append("    <inv:Remarks contextRef=\"c1\">" + json.getString("Remarks") + "</inv:Remarks>");
		sbxml.append("    <inv:Payee contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Payee") + "]]>");
		sbxml.append("    </inv:Payee>");
		sbxml.append("    <inv:Reviewer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Reviewer") + "]]>");
		sbxml.append("    </inv:Reviewer>");
		sbxml.append("    <inv:Issuer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Issuer") + "]]>");
		sbxml.append("    </inv:Issuer>");
		sbxml.append("    <inv:BeginningOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("BeginningOfIncomePeriodUnderAccrualBasis")
				+ "</inv:BeginningOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("    <inv:EndOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("EndOfIncomePeriodUnderAccrualBasis") + "</inv:EndOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("</xbrl>");
		return sbxml.toString();

	}

	/**
	 * (全电)电子发票(普通发票)
	 * 
	 * @param json
	 * @return
	 * @throws BusinessException
	 */
	public static String zjinv_feord_issuerXML(JSONObject json) throws BusinessException {
		StringBuilder sbxml = new StringBuilder();
		String xbrlId = json.getString("xbrlId");
		String a = json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller");
		String b = json.getString("NameOfSeller");
		String date = json.getString("DateOfIssue");
		String c = json.getString("UniqueCodeOfInvoice");
		String d = json.getString("xbrlId");
		Object jshjxx = json.get("TaxIncludedAmountInFigures"); // 价税合计（小写）
		Object jshjdx = json.get("TaxIncludedAmountInWords"); // 价税合计（大写）
		Object hj_je = json.get("TotalAmountExcludingTax"); // 合计_金额
		Object hj_se = json.get("TotalTaxAmount"); // 合计_税额
		insertVO(a, b, date, c, d, jshjxx, jshjdx, hj_je, hj_se);
		Object object = json.get("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
		sbxml.append("<xbrl xmlns=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:inv=\"http://xbrl.mof.gov.cn/taxonomy/" + date + "/inv\"");
		sbxml.append("    xmlns:link=\"http://www.xbrl.org/2003/linkbase\"");
		sbxml.append("    xmlns:iso4217=\"http://www.xbrl.org/2003/iso4217\"");
		sbxml.append("    xmlns:xbrli=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
		sbxml.append("    xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
		sbxml.append("	xsi:schemaLocation=\"http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-"
				+ date + ".xsd\">");
		sbxml.append("    <link:schemaRef xlink:type=\"simple\" xlink:href=\"" + xbrlId + "_entry_point_" + date
				+ ".xsd\"/>");
		sbxml.append("    <context id=\"c1\">");
		sbxml.append("        <entity>");
		sbxml.append("            <identifier scheme=\"http://xbrl.mof.gov.cn\">");
		sbxml.append("                <![CDATA[92330483MA2EWR3U6D]]>");
		sbxml.append("            </identifier>");
		sbxml.append("        </entity>");
		sbxml.append("        <period>");
		sbxml.append("            <instant>" + date + "</instant>");
		sbxml.append("        </period>");
		sbxml.append("    </context>");
		sbxml.append("    <unit id=\"u1\">");
		sbxml.append("        <measure>iso4217:CNY</measure>");
		sbxml.append("    </unit>");
		sbxml.append("    <inv:TypeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TypeOfInvoice") + "]]>");
		sbxml.append("    </inv:TypeOfInvoice>");
		sbxml.append("    <inv:UniqueCodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("UniqueCodeOfInvoice") + "]]>");
		sbxml.append("    </inv:UniqueCodeOfInvoice>");
		sbxml.append("    <inv:LocationOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("LocationOfInvoice") + "]]>");
		sbxml.append("    </inv:LocationOfInvoice>");
		sbxml.append("    <inv:CodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("CodeOfInvoice") + "]]>");
		sbxml.append("    </inv:CodeOfInvoice>");
		sbxml.append("    <inv:NumberOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoice") + "]]>");
		sbxml.append("    </inv:NumberOfInvoice>");
		sbxml.append("    <inv:DateOfIssue contextRef=\"c1\">" + date + "</inv:DateOfIssue>");
		sbxml.append("    <inv:IdentifyingCode contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("IdentifyingCode") + "]]>");
		sbxml.append("    </inv:IdentifyingCode>");
		sbxml.append("    <inv:NumberOfInvoiceMachine contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoiceMachine") + "]]>");
		sbxml.append("    </inv:NumberOfInvoiceMachine>");
		sbxml.append("    <inv:SpecialInvoiceType contextRef=\"c1\">" + json.getString("SpecialInvoiceType")
				+ "</inv:SpecialInvoiceType>");
		sbxml.append("    <inv:InvoiceIssuingSign contextRef=\"c1\">" + json.getString("InvoiceIssuingSign")
				+ "</inv:InvoiceIssuingSign>");
		sbxml.append("    <inv:NameOfPurchaser contextRef=\"c1\"> <![CDATA[" + json.getString("NameOfPurchaser")
				+ "]]> </inv:NameOfPurchaser>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser contextRef=\"c1\"> "
				+ " <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser")
				+ "]]> " + "</inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser>");
		sbxml.append("    <inv:AddressPhoneNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("AddressPhoneNumberOfPurchaser") + "</inv:AddressPhoneNumberOfPurchaser>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("DepositBankAndAccountNumberOfPurchaser")
				+ "</inv:DepositBankAndAccountNumberOfPurchaser>");
		sbxml.append("    <inv:TotalAmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalAmountExcludingTax") + "</inv:TotalAmountExcludingTax>");
		sbxml.append("    <inv:TotalTaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalTaxAmount") + "</inv:TotalTaxAmount>");
		sbxml.append("    <inv:TaxIncludedAmountInWords contextRef=\"c1\">  <![CDATA["
				+ json.getString("TaxIncludedAmountInWords") + "]]> </inv:TaxIncludedAmountInWords>");
		sbxml.append("    <inv:TaxIncludedAmountInFigures contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TaxIncludedAmountInFigures") + "</inv:TaxIncludedAmountInFigures>");
		if (object instanceof com.alibaba.fastjson.JSONArray) {
			JSONArray jsonarr = json.getJSONArray("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			for (int i = 0; i < jsonarr.size(); i++) {
				JSONObject item = jsonarr.getJSONObject(i);
				sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
				sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
				sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
				sbxml.append("        </inv:TaxClassificationCode>");
				sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
				sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
				sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
						+ "</inv:Specification>");
				sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
				sbxml.append("        </inv:UnitOfGoodsOrServices>");
				sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
				sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
				sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
				sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
				sbxml.append("        </inv:TaxRate>");
				sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("TaxAmount") + "</inv:TaxAmount>");
				sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			}
		} else {
			JSONObject item = json.getJSONObject("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
			sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
			sbxml.append("        </inv:TaxClassificationCode>");
			sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
			sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
			sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
					+ "</inv:Specification>");
			sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
			sbxml.append("        </inv:UnitOfGoodsOrServices>");
			sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
			sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
			sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
			sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
			sbxml.append("        </inv:TaxRate>");
			sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("TaxAmount") + "</inv:TaxAmount>");
			sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");

		}
		sbxml.append("    <inv:NameOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NameOfSeller") + "]]>");
		sbxml.append("    </inv:NameOfSeller>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller")
				+ "]]>");
		sbxml.append("    </inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller>");
		sbxml.append("    <inv:AddressPhoneNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("AddressPhoneNumberOfSeller") + "]]>");
		sbxml.append("    </inv:AddressPhoneNumberOfSeller>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("DepositBankAndAccountNumberOfSeller") + "]]>");
		sbxml.append("    </inv:DepositBankAndAccountNumberOfSeller>");
		sbxml.append("    <inv:Remarks contextRef=\"c1\">" + json.getString("Remarks") + "</inv:Remarks>");
		sbxml.append("    <inv:Payee contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Payee") + "]]>");
		sbxml.append("    </inv:Payee>");
		sbxml.append("    <inv:Reviewer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Reviewer") + "]]>");
		sbxml.append("    </inv:Reviewer>");
		sbxml.append("    <inv:Issuer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Issuer") + "]]>");
		sbxml.append("    </inv:Issuer>");
		sbxml.append("    <inv:BeginningOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("BeginningOfIncomePeriodUnderAccrualBasis")
				+ "</inv:BeginningOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("    <inv:EndOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("EndOfIncomePeriodUnderAccrualBasis") + "</inv:EndOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("</xbrl>");
		return sbxml.toString();

	}

	/**
	 * (全电)电子发票(增值税专用发票)
	 * 
	 * @param json
	 * @return
	 * @throws BusinessException
	 */
	public static String zjinv_fespcl_issuerXML(JSONObject json) throws BusinessException {
		StringBuilder sbxml = new StringBuilder();
		String xbrlId = json.getString("xbrlId");
		String a = json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller");
		String b = json.getString("NameOfSeller");
		String date = json.getString("DateOfIssue");
		String c = json.getString("UniqueCodeOfInvoice");
		String d = json.getString("xbrlId");
		Object jshjxx = json.get("TaxIncludedAmountInFigures"); // 价税合计（小写）
		Object jshjdx = json.get("TaxIncludedAmountInWords"); // 价税合计（大写）
		Object hj_je = json.get("TotalAmountExcludingTax"); // 合计_金额
		Object hj_se = json.get("TotalTaxAmount"); // 合计_税额
		insertVO(a, b, date, c, d, jshjxx, jshjdx, hj_je, hj_se);
		Object object = json.get("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
		sbxml.append("<xbrl xmlns=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:inv=\"http://xbrl.mof.gov.cn/taxonomy/" + date + "/inv\"");
		sbxml.append("    xmlns:link=\"http://www.xbrl.org/2003/linkbase\"");
		sbxml.append("    xmlns:iso4217=\"http://www.xbrl.org/2003/iso4217\"");
		sbxml.append("    xmlns:xbrli=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
		sbxml.append("    xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
		sbxml.append("	xsi:schemaLocation=\"http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-"
				+ date + ".xsd\">");
		sbxml.append("    <link:schemaRef xlink:type=\"simple\" xlink:href=\"" + xbrlId + "_entry_point_" + date
				+ ".xsd\"/>");
		sbxml.append("    <context id=\"c1\">");
		sbxml.append("        <entity>");
		sbxml.append("            <identifier scheme=\"http://xbrl.mof.gov.cn\">");
		sbxml.append("                <![CDATA[92330483MA2EWR3U6D]]>");
		sbxml.append("            </identifier>");
		sbxml.append("        </entity>");
		sbxml.append("        <period>");
		sbxml.append("            <instant>" + date + "</instant>");
		sbxml.append("        </period>");
		sbxml.append("    </context>");
		sbxml.append("    <unit id=\"u1\">");
		sbxml.append("        <measure>iso4217:CNY</measure>");
		sbxml.append("    </unit>");
		sbxml.append("    <inv:TypeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TypeOfInvoice") + "]]>");
		sbxml.append("    </inv:TypeOfInvoice>");
		sbxml.append("    <inv:UniqueCodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("UniqueCodeOfInvoice") + "]]>");
		sbxml.append("    </inv:UniqueCodeOfInvoice>");
		sbxml.append("    <inv:LocationOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("LocationOfInvoice") + "]]>");
		sbxml.append("    </inv:LocationOfInvoice>");
		sbxml.append("    <inv:CodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("CodeOfInvoice") + "]]>");
		sbxml.append("    </inv:CodeOfInvoice>");
		sbxml.append("    <inv:NumberOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoice") + "]]>");
		sbxml.append("    </inv:NumberOfInvoice>");
		sbxml.append("    <inv:DateOfIssue contextRef=\"c1\">" + date + "</inv:DateOfIssue>");
		sbxml.append("    <inv:IdentifyingCode contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("IdentifyingCode") + "]]>");
		sbxml.append("    </inv:IdentifyingCode>");
		sbxml.append("    <inv:NumberOfInvoiceMachine contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoiceMachine") + "]]>");
		sbxml.append("    </inv:NumberOfInvoiceMachine>");
		sbxml.append("    <inv:SpecialInvoiceType contextRef=\"c1\">" + json.getString("SpecialInvoiceType")
				+ "</inv:SpecialInvoiceType>");
		sbxml.append("    <inv:InvoiceIssuingSign contextRef=\"c1\">" + json.getString("InvoiceIssuingSign")
				+ "</inv:InvoiceIssuingSign>");
		sbxml.append("    <inv:NameOfPurchaser contextRef=\"c1\"> <![CDATA[" + json.getString("NameOfPurchaser")
				+ "]]> </inv:NameOfPurchaser>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser contextRef=\"c1\"> "
				+ " <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser")
				+ "]]> " + "</inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser>");
		sbxml.append("    <inv:AddressPhoneNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("AddressPhoneNumberOfPurchaser") + "</inv:AddressPhoneNumberOfPurchaser>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("DepositBankAndAccountNumberOfPurchaser")
				+ "</inv:DepositBankAndAccountNumberOfPurchaser>");
		sbxml.append("    <inv:TotalAmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalAmountExcludingTax") + "</inv:TotalAmountExcludingTax>");
		sbxml.append("    <inv:TotalTaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalTaxAmount") + "</inv:TotalTaxAmount>");
		sbxml.append("    <inv:TaxIncludedAmountInWords contextRef=\"c1\">  <![CDATA["
				+ json.getString("TaxIncludedAmountInWords") + "]]> </inv:TaxIncludedAmountInWords>");
		sbxml.append("    <inv:TaxIncludedAmountInFigures contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TaxIncludedAmountInFigures") + "</inv:TaxIncludedAmountInFigures>");
		if (object instanceof com.alibaba.fastjson.JSONArray) {
			JSONArray jsonarr = json.getJSONArray("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			for (int i = 0; i < jsonarr.size(); i++) {
				JSONObject item = jsonarr.getJSONObject(i);
				sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
				sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
				sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
				sbxml.append("        </inv:TaxClassificationCode>");
				sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
				sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
				sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
						+ "</inv:Specification>");
				sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
				sbxml.append("        </inv:UnitOfGoodsOrServices>");
				sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
				sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
				sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
				sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
				sbxml.append("        </inv:TaxRate>");
				sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("TaxAmount") + "</inv:TaxAmount>");
				sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			}
		} else {
			JSONObject item = json.getJSONObject("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
			sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
			sbxml.append("        </inv:TaxClassificationCode>");
			sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
			sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
			sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
					+ "</inv:Specification>");
			sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
			sbxml.append("        </inv:UnitOfGoodsOrServices>");
			sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
			sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
			sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
			sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
			sbxml.append("        </inv:TaxRate>");
			sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("TaxAmount") + "</inv:TaxAmount>");
			sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");

		}
		sbxml.append("    <inv:NameOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NameOfSeller") + "]]>");
		sbxml.append("    </inv:NameOfSeller>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller")
				+ "]]>");
		sbxml.append("    </inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller>");
		sbxml.append("    <inv:AddressPhoneNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("AddressPhoneNumberOfSeller") + "]]>");
		sbxml.append("    </inv:AddressPhoneNumberOfSeller>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("DepositBankAndAccountNumberOfSeller") + "]]>");
		sbxml.append("    </inv:DepositBankAndAccountNumberOfSeller>");
		sbxml.append("    <inv:Remarks contextRef=\"c1\">" + json.getString("Remarks") + "</inv:Remarks>");
		sbxml.append("    <inv:Payee contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Payee") + "]]>");
		sbxml.append("    </inv:Payee>");
		sbxml.append("    <inv:Reviewer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Reviewer") + "]]>");
		sbxml.append("    </inv:Reviewer>");
		sbxml.append("    <inv:Issuer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Issuer") + "]]>");
		sbxml.append("    </inv:Issuer>");
		sbxml.append("    <inv:BeginningOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("BeginningOfIncomePeriodUnderAccrualBasis")
				+ "</inv:BeginningOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("    <inv:EndOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("EndOfIncomePeriodUnderAccrualBasis") + "</inv:EndOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("</xbrl>");
		return sbxml.toString();

	}
	/**
	 * xml默认解析格式
	 * @param json
	 * @return
	 * @throws BusinessException
	 */
	public static String otherXml(JSONObject json) throws BusinessException {
		StringBuilder sbxml = new StringBuilder();
		String xbrlId = json.getString("xbrlId");
		String a = json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller");
		String b = json.getString("NameOfSeller");
		String date = json.getString("DateOfIssue");
		String c = json.getString("UniqueCodeOfInvoice");
		String d = json.getString("xbrlId");
		Object jshjxx = json.get("TaxIncludedAmountInFigures"); // 价税合计（小写）
		Object jshjdx = json.get("TaxIncludedAmountInWords"); // 价税合计（大写）
		Object hj_je = json.get("TotalAmountExcludingTax"); // 合计_金额
		Object hj_se = json.get("TotalTaxAmount"); // 合计_税额
		insertVO(a, b, date, c, d, jshjxx, jshjdx, hj_je, hj_se);
		Object object = json.get("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
		sbxml.append("<xbrl xmlns=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:inv=\"http://xbrl.mof.gov.cn/taxonomy/" + date + "/inv\"");
		sbxml.append("    xmlns:link=\"http://www.xbrl.org/2003/linkbase\"");
		sbxml.append("    xmlns:iso4217=\"http://www.xbrl.org/2003/iso4217\"");
		sbxml.append("    xmlns:xbrli=\"http://www.xbrl.org/2003/instance\"");
		sbxml.append("    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"");
		sbxml.append("    xmlns:xlink=\"http://www.w3.org/1999/xlink\" ");
		sbxml.append("	xsi:schemaLocation=\"http://www.xbrl.org/2003/linkbase http://www.xbrl.org/2003/xbrl-linkbase-"
				+ date + ".xsd\">");
		sbxml.append("    <link:schemaRef xlink:type=\"simple\" xlink:href=\"" + xbrlId + "_entry_point_" + date
				+ ".xsd\"/>");
		sbxml.append("    <context id=\"c1\">");
		sbxml.append("        <entity>");
		sbxml.append("            <identifier scheme=\"http://xbrl.mof.gov.cn\">");
		sbxml.append("                <![CDATA[92330483MA2EWR3U6D]]>");
		sbxml.append("            </identifier>");
		sbxml.append("        </entity>");
		sbxml.append("        <period>");
		sbxml.append("            <instant>" + date + "</instant>");
		sbxml.append("        </period>");
		sbxml.append("    </context>");
		sbxml.append("    <unit id=\"u1\">");
		sbxml.append("        <measure>iso4217:CNY</measure>");
		sbxml.append("    </unit>");
		sbxml.append("    <inv:TypeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TypeOfInvoice") + "]]>");
		sbxml.append("    </inv:TypeOfInvoice>");
		sbxml.append("    <inv:UniqueCodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("UniqueCodeOfInvoice") + "]]>");
		sbxml.append("    </inv:UniqueCodeOfInvoice>");
		sbxml.append("    <inv:LocationOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("LocationOfInvoice") + "]]>");
		sbxml.append("    </inv:LocationOfInvoice>");
		sbxml.append("    <inv:CodeOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("CodeOfInvoice") + "]]>");
		sbxml.append("    </inv:CodeOfInvoice>");
		sbxml.append("    <inv:NumberOfInvoice contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoice") + "]]>");
		sbxml.append("    </inv:NumberOfInvoice>");
		sbxml.append("    <inv:DateOfIssue contextRef=\"c1\">" + date + "</inv:DateOfIssue>");
		sbxml.append("    <inv:IdentifyingCode contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("IdentifyingCode") + "]]>");
		sbxml.append("    </inv:IdentifyingCode>");
		sbxml.append("    <inv:NumberOfInvoiceMachine contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NumberOfInvoiceMachine") + "]]>");
		sbxml.append("    </inv:NumberOfInvoiceMachine>");
		sbxml.append("    <inv:SpecialInvoiceType contextRef=\"c1\">" + json.getString("SpecialInvoiceType")
				+ "</inv:SpecialInvoiceType>");
		sbxml.append("    <inv:InvoiceIssuingSign contextRef=\"c1\">" + json.getString("InvoiceIssuingSign")
				+ "</inv:InvoiceIssuingSign>");
		sbxml.append("    <inv:NameOfPurchaser contextRef=\"c1\"> <![CDATA[" + json.getString("NameOfPurchaser")
				+ "]]> </inv:NameOfPurchaser>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser contextRef=\"c1\"> "
				+ " <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser")
				+ "]]> " + "</inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfPurchaser>");
		sbxml.append("    <inv:AddressPhoneNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("AddressPhoneNumberOfPurchaser") + "</inv:AddressPhoneNumberOfPurchaser>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfPurchaser contextRef=\"c1\">"
				+ json.getString("DepositBankAndAccountNumberOfPurchaser")
				+ "</inv:DepositBankAndAccountNumberOfPurchaser>");
		sbxml.append("    <inv:TotalAmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalAmountExcludingTax") + "</inv:TotalAmountExcludingTax>");
		sbxml.append("    <inv:TotalTaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TotalTaxAmount") + "</inv:TotalTaxAmount>");
		sbxml.append("    <inv:TaxIncludedAmountInWords contextRef=\"c1\">  <![CDATA["
				+ json.getString("TaxIncludedAmountInWords") + "]]> </inv:TaxIncludedAmountInWords>");
		sbxml.append("    <inv:TaxIncludedAmountInFigures contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
				+ json.getString("TaxIncludedAmountInFigures") + "</inv:TaxIncludedAmountInFigures>");
		if (object instanceof com.alibaba.fastjson.JSONArray) {
			JSONArray jsonarr = json.getJSONArray("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			for (int i = 0; i < jsonarr.size(); i++) {
				JSONObject item = jsonarr.getJSONObject(i);
				sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
				sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
				sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
				sbxml.append("        </inv:TaxClassificationCode>");
				sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
				sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
				sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
						+ "</inv:Specification>");
				sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
				sbxml.append("        </inv:UnitOfGoodsOrServices>");
				sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
				sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
				sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
				sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
				sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
				sbxml.append("        </inv:TaxRate>");
				sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
						+ item.getString("TaxAmount") + "</inv:TaxAmount>");
				sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			}
		} else {
			JSONObject item = json.getJSONObject("InformationOfTaxableGoodsOrServicesDetailItemsTuple");
			sbxml.append("    <inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");
			sbxml.append("        <inv:NatureOfInvoiceLine contextRef=\"c1\"></inv:NatureOfInvoiceLine>");
			sbxml.append("        <inv:TaxClassificationCode contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxClassificationCode") + "]]>");
			sbxml.append("        </inv:TaxClassificationCode>");
			sbxml.append("        <inv:NameOfTaxableGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("NameOfTaxableGoodsOrServices") + "]]>");
			sbxml.append("        </inv:NameOfTaxableGoodsOrServices>");
			sbxml.append("        <inv:Specification contextRef=\"c1\">" + item.getString("Specification")
					+ "</inv:Specification>");
			sbxml.append("        <inv:UnitOfGoodsOrServices contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("UnitOfGoodsOrServices") + "]]>");
			sbxml.append("        </inv:UnitOfGoodsOrServices>");
			sbxml.append("        <inv:QuantityOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("QuantityOfGoodsOrServices") + "</inv:QuantityOfGoodsOrServices>");
			sbxml.append("        <inv:UnitPriceOfGoodsOrServices contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("UnitPriceOfGoodsOrServices") + "</inv:UnitPriceOfGoodsOrServices>");
			sbxml.append("        <inv:AmountExcludingTax contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("AmountExcludingTax") + "</inv:AmountExcludingTax>");
			sbxml.append("        <inv:TaxRate contextRef=\"c1\">");
			sbxml.append("            <![CDATA[" + item.getString("TaxRate") + "]]>");
			sbxml.append("        </inv:TaxRate>");
			sbxml.append("        <inv:TaxAmount contextRef=\"c1\" unitRef=\"u1\" decimals=\"2\">"
					+ item.getString("TaxAmount") + "</inv:TaxAmount>");
			sbxml.append("    </inv:InformationOfTaxableGoodsOrServicesDetailItemsTuple>");

		}
		sbxml.append("    <inv:NameOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("NameOfSeller") + "]]>");
		sbxml.append("    </inv:NameOfSeller>");
		sbxml.append("    <inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller")
				+ "]]>");
		sbxml.append("    </inv:TaxpayerIdentificationNumberUnifiedSocialCreditCodeOfSeller>");
		sbxml.append("    <inv:AddressPhoneNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("AddressPhoneNumberOfSeller") + "]]>");
		sbxml.append("    </inv:AddressPhoneNumberOfSeller>");
		sbxml.append("    <inv:DepositBankAndAccountNumberOfSeller contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("DepositBankAndAccountNumberOfSeller") + "]]>");
		sbxml.append("    </inv:DepositBankAndAccountNumberOfSeller>");
		sbxml.append("    <inv:Remarks contextRef=\"c1\">" + json.getString("Remarks") + "</inv:Remarks>");
		sbxml.append("    <inv:Payee contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Payee") + "]]>");
		sbxml.append("    </inv:Payee>");
		sbxml.append("    <inv:Reviewer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Reviewer") + "]]>");
		sbxml.append("    </inv:Reviewer>");
		sbxml.append("    <inv:Issuer contextRef=\"c1\">");
		sbxml.append("        <![CDATA[" + json.getString("Issuer") + "]]>");
		sbxml.append("    </inv:Issuer>");
		sbxml.append("    <inv:BeginningOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("BeginningOfIncomePeriodUnderAccrualBasis")
				+ "</inv:BeginningOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("    <inv:EndOfIncomePeriodUnderAccrualBasis contextRef=\"c1\">"
				+ json.getString("EndOfIncomePeriodUnderAccrualBasis") + "</inv:EndOfIncomePeriodUnderAccrualBasis>");
		sbxml.append("</xbrl>");
		return sbxml.toString();

	}

	/**
	 * 
	 * @param a      销售方_纳税人识别号
	 * @param b      销售方_名称
	 * @param date   开票日期
	 * @param d      发票唯一标识
	 * @param e      发票类型
	 * @param jshjxx 价税合计（小写）
	 * @param jshjdx 价税合计（大写）
	 * @param hj_je  合计金额
	 * @param hj_se  合计_税额
	 * @throws BusinessException
	 */
	private static void insertVO(String a, String b, String date, String d, String e, Object jshjxx, Object jshjdx,
			Object hj_je, Object hj_se) throws BusinessException {
		Object code = dao.executeQuery("select UniqueCodeOfInvoice from DQFP where UniqueCodeOfInvoice = '" + d + "'",
				new ColumnProcessor());
		if (code == null) {
			dao.executeUpdate("insert into DQFP(taxpayeri,"
					+ "NameOfSeller,DateOfIssue,UniqueCodeOfInvoice,xbrlId,jshjxx,jshjdx,hj_je,hj_se) " + "values('" + a
					+ "','" + b + "','" + date + "','" + d + "', '" + e + "','" + jshjxx + "','" + jshjdx + "','"
					+ hj_je + "','" + hj_se + "')");
			dao.executeUpdate("commit;");
		}
	}

}
